Completed
Pull Request — develop (#85)
by Xaver
01:06
created

L.CircleMarker.extend.setLatLng   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 5
rs 9.4285
nop 1
1
define(['leaflet'], function (L) {
2
  'use strict';
3
4
  return L.CircleMarker.extend({
5
    outerCircle: {
6
      stroke: false,
7
      color: '#4285F4',
8
      opacity: 1,
9
      fillOpacity: 0.3,
10
      clickable: false,
11
      radius: 16
12
    },
13
14
    innerCircle: {
15
      stroke: true,
16
      color: '#ffffff',
17
      fillColor: '#4285F4',
18
      weight: 1.5,
19
      clickable: false,
20
      opacity: 1,
21
      fillOpacity: 1,
22
      radius: 7
23
    },
24
25
    accuracyCircle: {
26
      stroke: true,
27
      color: '#4285F4',
28
      weight: 1,
29
      clickable: false,
30
      opacity: 0.7,
31
      fillOpacity: 0.2
32
    },
33
34
    initialize: function (latlng) {
35
      this.accuracyCircle = L.circle(latlng, 0, this.accuracyCircle);
36
      this.outerCircle = L.circleMarker(latlng, this.outerCircle);
37
      L.CircleMarker.prototype.initialize.call(this, latlng, this.innerCircle);
38
39
      this.on('remove', function () {
40
        this._map.removeLayer(this.accuracyCircle);
41
        this._map.removeLayer(this.outerCircle);
42
      });
43
    },
44
45
    setLatLng: function (latlng) {
46
      this.accuracyCircle.setLatLng(latlng);
47
      this.outerCircle.setLatLng(latlng);
48
      L.CircleMarker.prototype.setLatLng.call(this, latlng);
49
    },
50
51
    setAccuracy: function (accuracy) {
52
      this.accuracyCircle.setRadius(accuracy);
53
    },
54
55
    onAdd: function (map) {
56
      this.accuracyCircle.addTo(map).bringToBack();
57
      this.outerCircle.addTo(map);
58
      L.CircleMarker.prototype.onAdd.call(this, map);
59
    }
60
  });
61
});
62